package com.zp.datax.core;

import lombok.Setter;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * id过虑器
 *
 * @author bruce
 * @date 2019-07-15
 */
@Setter
public class IdFilterHandler implements Handler {

//    private final static Pattern PATTERN_PROCESS_MAX_ID = Pattern.compile(".+本次处理数据的最大id\\s+:\\s+(\\d+)$");
    private final static Pattern PATTERN_PROCESS_MAX_ID = Pattern.compile(".+本次处理数据的最大实际id\\s+:\\s+(\\d+)$");

    private Handler handler;

    @Override
    public Object[] handler(String str) {

        Matcher matcher = matcher(PATTERN_PROCESS_MAX_ID, str.trim());

        if (matcher.matches()) {
            return new String[]{"maxid", matcher.group(1)};
        }

        return handler(handler, str);
    }
}
